package cn.bdqn.t354.service.impl;

import cn.bdqn.t354.mapper.StorageMapper;
import cn.bdqn.t354.pojo.Storage;
import cn.bdqn.t354.service.StorageService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class StorageServiceImpl implements StorageService {
    @Resource
    StorageMapper storageMapper;

    @Override
    public IPage<Storage> getStoragesByPage(String prodName, String stkWarehouse,
                                            Integer pageNo, Integer pageSize) {
        //组装分页条件
        Page<Storage> page=new Page<>(pageNo,pageSize);

        //组装过滤条件 动态sql
        Map<String,Object> param=new HashMap<>();
        param.put("prodName",prodName);
        param.put("stkWarehouse",stkWarehouse);

        //调用分页方法
        IPage<Storage> storagePage=storageMapper.getStoragesByPage(page, param);

        //返回分页对象
        return storagePage;
    }
}
